import asyncio

class FooBar():
    def __init__(self, n):
        self.n = n

    @asyncio.coroutine
    def foo(self):
        for i in range(self.n):
            print('foo', end="")
            yield

    @asyncio.coroutine
    def bar(self):
        for i in range(self.n):
            print('bar', end="")
            yield


obj = FooBar(3)
loop = asyncio.get_event_loop()
loop.run_until_complete(asyncio.wait([obj.foo(), obj.bar()]))

# 这个也没能输出正确答案，尝试再修改一下